The Python Workbook by Ben Stephenson
Author:Ben Stephenson
Language: eng
Format: epub, pdf
ISBN: 9783030188733
Publisher: Springer International Publishing
Exercise 107: Reduce a Fraction to Lowest Terms
(Solved, 46 Lines)
Write a function that takes two positive integers that represent the numerator and denominator of a fraction as its only parameters. The body of the function should reduce the fraction to lowest terms and then return both the numerator and denominator of the reduced fraction as its result. For example, if the parameters passed to the function are 6 and 63 then the function should return 2 and 21. Include a main program that allows the user to enter a numerator and denominator. Then your program should display the reduced fraction.
Hint: In Exercise 79 you wrote a program for computing the greatest common divisor of two positive integers. You may find that code useful when completing this exercise.
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Computer Vision & Pattern Recognition | Expert Systems |
Intelligence & Semantics | Machine Theory |
Natural Language Processing | Neural Networks |
Algorithms of the Intelligent Web by Haralambos Marmanis;Dmitry Babenko(7901)
Hadoop in Practice by Alex Holmes(5687)
Jquery UI in Action : Master the concepts Of Jquery UI: A Step By Step Approach by ANMOL GOYAL(5543)
Life 3.0: Being Human in the Age of Artificial Intelligence by Tegmark Max(4559)
Functional Programming in JavaScript by Mantyla Dan(3748)
The Age of Surveillance Capitalism by Shoshana Zuboff(3470)
Big Data Analysis with Python by Ivan Marin(3317)
Test-Driven Development with Java by Alan Mellor(2976)
Blockchain Basics by Daniel Drescher(2930)
Data Augmentation with Python by Duc Haba(2815)
The Rosie Effect by Graeme Simsion(2751)
WordPress Plugin Development Cookbook by Yannick Lefebvre(2698)
Principles of Data Fabric by Sonia Mezzetta(2629)
Hands-On Machine Learning for Algorithmic Trading by Stefan Jansen(2613)
Applied Predictive Modeling by Max Kuhn & Kjell Johnson(2521)
The Infinite Retina by Robert Scoble Irena Cronin(2485)
Dawn of the New Everything by Jaron Lanier(2467)
Microservices with Spring Boot 3 and Spring Cloud by Magnus Larsson(2407)
Learn Blender Simulations the Right Way by Stephen Pearson(2393)